package cn.edu.zknu.mita.controller;

import cn.edu.zknu.mita.model.Thank;
import cn.edu.zknu.mita.service.IThankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ThankController {

    @Autowired
    private IThankService thankService;

    @RequestMapping("/thank")
    public String toThank(){
        return "thank";
    }

    @RequestMapping("/releaseThank")
    public String releaseThank(Thank thank){
        thankService.releaseThank(thank);
        return "redirect:/index";
    }

    @RequestMapping("/thankDetail")
    public String thankDetail(Long id, Model model){
        model.addAttribute("thank",thankService.getThankById(id));
        return "ThankDetail";
    }
}
